package com.jarvis.user.controller;


import com.jarvis.common.utils.R;
import com.jarvis.user.entity.UserEntity;
import com.jarvis.user.entity.UserRecordEntity;
import com.jarvis.user.service.UserRecordService;
import com.jarvis.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class FeignController {

    @Autowired
    private UserService userService;

    @Autowired
    private UserRecordService userRecordService;

    @RequestMapping("/chat/{userId}")
    public UserEntity getUser(@PathVariable("userId") long userId){
        return userService.getUser(userId);
    }

    @RequestMapping("/reduceFreeCount/{userId}")
    public R reduceFreeCount(@PathVariable("userId") long userId){
        userService.reduceUserFreecount(userId);
        return R.ok();
    }
    @RequestMapping("/addVipDay")
    public R addVipDay(@RequestParam("userId") long userId,@RequestParam("day") int day){
        System.out.print("用户id"+(userId)+"天数"+(day));

        userService.addVipDay(userId,day);
        return R.ok();
    }

    /**
     * 保存
     */
    @RequestMapping("/addRecord")
    public R save(@RequestBody UserRecordEntity userRecord){
        UserRecordEntity entity =  userRecordService.addRecord(userRecord);
        return R.ok().put("data",entity);
    }








}
